package gbench.sandbox.record.cph;

import static java.util.Arrays.asList;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.Test;

import gbench.common.tree.LittleTree.Elem;
import gbench.common.tree.LittleTree.IRecord;
import gbench.common.tree.LittleTree.KVPair;

import static gbench.common.tree.LittleTree.IRecord.*;
import static gbench.common.tree.LittleTree.JOIN;

/**
 * pathvalues 的层级结构
 * @author gbench
 *
 */
public class JunitPathValues {
    @Test
    public void foo() {
        final var digits = "0123456789".split(""); 
        final var ai = new AtomicInteger(0); 
        Elem.cph2(asList(digits,digits,digits,digits,digits)).map(IRecord::L2REC) 
        .map(path->REC(JOIN(path.ss().subList(0, 4)), ai.getAndIncrement() )) // 生成一个 path2value结构,这是一种阶层结构的方法方法 
        .collect(llclc(IRecord::RECMERGE2)) // 阶层化 Record 集合 
        .dfs_forall2(System.out::println); 
    }
    
    @Test
    public void bar() {
        System.out.println("initial2last");
        System.out.println(KVPair.initial2last(L(1,2,3)));
        System.out.println(KVPair.initial2last(L(1)));
        System.out.println(KVPair.initial2last(L()));
        
        System.out.println("head2tail");
        System.out.println(KVPair.head2tail(L(1,2,3)));
        System.out.println(KVPair.head2tail(L(1)));
        System.out.println(KVPair.head2tail(L()));
    }
}
